
import 'dart:ffi';

import 'package:flutter/services.dart';
class Fphonelocation {
  static final _methodChannel = MethodChannel('com.lx.fnativelocation');

  static void init({ bool? isSingle, int? delayMilTime}){
    var initMap = Map();
    initMap['isSingle'] = (isSingle??false);
    initMap['delayMilTime'] = (delayMilTime??5000);
    _methodChannel.invokeMethod('init',initMap);
  }

  static void startLocation(){
    _methodChannel.invokeMethod('startLocation');
  }
  static void stopLocation(){
    _methodChannel.invokeMethod('stopLocation');
  }
  static setLocationCall({required Function(double latitude,double longitude) locationCall}){
    _methodChannel.setMethodCallHandler((call)async{
      var method = call.method;
      var arguments = call.arguments;
      print('--->method=$method,arguments=$arguments');
      switch(method){
        case "locationCall":
          if(arguments!=null){
            Map locations = arguments as Map;
            locationCall(locations['latitude'] as double,locations['longitude']  as double);
          }
          break;
      }
    });
  }
}
